package com.gosophia.dataDictionary.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseAjaxAction;
import com.gosophia.dataDictionary.dto.DataEntryDTO;
import com.gosophia.dataDictionary.ws.DataDictionaryWebService;

/**
 * 进入编辑词条界面
 * 
 * @author tianchunyu
 * 
 */
@Controller
@Scope("prototype")
public class FindEntryAction extends BaseAjaxAction<DataEntryDTO> {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Override
    public DataEntryDTO getDetailData() {
        if (this.detailData == null) {
            this.detailData = new DataEntryDTO();
        }
        return this.detailData;
    }

    @Autowired
    private DataDictionaryWebService dataDictionaryWebService;

    private Long entryId;

    @Override
    public String _execute() throws Exception {
        this.detailData = dataDictionaryWebService
                .findDataEntryByDataEntryId(entryId);

        super.getRequestResult().setRsltCode("0");

        if (this.detailData != null
                && "内置".equals(this.detailData.getEntryType())) {
            return "builtin";
        } else {
            return "custom";
        }
    }

    public Long getEntryId() {
        return entryId;
    }

    public void setEntryId(Long entryId) {
        this.entryId = entryId;
    }

}
